/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.baatar.opt.pga.impl.client;

import org.baatar.net.client.TCPClient;
import org.baatar.opt.genetic.chromosome.MigrantChromosome;
import org.baatar.opt.pga.intf.IPGACluster;
import org.baatar.remoting.message.RemoteRequest;
import org.baatar.remoting.service.RemotingServiceInfo;

/**
 *
 * @author Ba
 */
public class PGAClusterConnection<T, M> extends TCPClient implements IPGACluster<T, M> {
//    @Override
//    public Integer registerCoordinator(RemotingServiceInfo coordinatorNetInfo, Integer clusterIndex, AlgorithmParameters<T, M> algoPref) throws Exception {
//        return sendMessage(new RemoteRequest(callerInfo, "registerCoordinator", coordinatorNetInfo, clusterIndex, algoPref), Integer.class).getResult();
//    }

    @Override
    public RemotingServiceInfo getClusterNetInfo() throws Exception {
        return sendMessage(new RemoteRequest(callerInfo, "getClusterNetInfo"), RemotingServiceInfo.class).getResult();
    }

    @Override
    public Integer prepareOptimizers() throws Exception {
        return sendMessage(new RemoteRequest(callerInfo, "prepareOptimizers"), Integer.class).getResult();
    }

    @Override
    public Integer runOptimizers() throws Exception {
        return sendMessage(new RemoteRequest(callerInfo, "runOptimizers"), Integer.class).getResult();
    }

    @Override
    public void migrate(MigrantChromosome<M> migrants[]) throws Exception {
        sendMessage(new RemoteRequest(callerInfo, "migrate", migrants), Void.class);
    }

    @Override
    public void waitForOptimizers() throws Exception {
        sendMessage(new RemoteRequest(callerInfo, "waitForOptimizers"), Void.class);
    }

}
